! ls -lt /scratch/users/swmclau2/PearceMCMC/*.hdf5
Out[98]:
[u'chain_fixed_params',
u'cov',
u'dlogz',
u'emu_cov_fname',
u'emu_hps',
u'emu_type',
u'fixed_params',
u'mcmc_type',
u'nburn',
u'nlive',
u'nsteps',
u'nwalkers',
u'obs',
u'param_names',
u'seed',
u'sim',
u'training_file',
u'true_cov_fname',
u'true_data_fname']
f['cov'].value
try:
del fixed_params['rmin'] # don't want this rn
except KeyError:
pass
Out[101]:
array(['/home/users/swmclau2/scratch/wp_zheng07/PearceWpCosmo.hdf5',
'/home/users/swmclau2/scratch/ds_zheng07/PearceDsCosmo.hdf5'],
dtype='|S58')
sim_info = literal_eval(f.attrs['sim'])
chain_pnames = f.attrs['param_names']
[ 2.2100806e-02 1.1676930e-01 -1.0303556e+00 9.6384913e-01
3.0928123e+00 6.5362617e+01 3.4123785e+00 1.4258521e+01
1.3172162e+01 2.5067803e-01 1.0673476e+00 7.1900249e-01]
Out[112]:
array(['ombh2', 'omch2', 'w0', 'ns', 'ln10As', 'H0', 'Neff', 'logM1',
'logM0', 'sigma_logM', 'alpha', 'conc_gal_bias'], dtype='|S13')
sns.jointplot(chain[:,0], chain[:, 2], kind='hex', space = 0)
for i in xrange(chain.shape[1]):
fig = plt.figure(figsize = (8,6))
plt.suptitle(chain_pnames[i])
#plt.subplot(121)
sns.distplot(low_om_chain[:, i])#, alpha = 0.6)
#plt.subplot(122)
sns.distplot(med_om_chain[:,i], color = 'g')#, alpha = 0.6)
sns.distplot(high_om_chain[:,i], color = 'r')#, alpha = 0.6)
plt.show()
Out[115]:
{'H0': 65.36262,
'Neff': 3.4123785,
'alpha': 1.0673476,
'conc_gal_bias': 0.7190025,
'ln10As': 3.0928123,
'logM0': 13.172162,
'logM1': 14.258521,
'ns': 0.9638491,
'ombh2': 0.022100806,
'omch2': 0.1167693,
'sigma_logM': 0.25067803,
'w0': -1.0303556}
Out[118]:
{'H0': 65.36262,
'Neff': 3.4123785,
'alpha': 1.0673476,
'conc_gal_bias': 0.7190025,
'ln10As': 3.0928123,
'logM0': 13.172162,
'logM1': 14.258521,
'ns': 0.9638491,
'ombh2': 0.022100806,
'omch2': 0.1167693,
'sigma_logM': 0.25067803,
'w0': -1.0303556}
Out[120]:
array([ 2.16416461, 2.11650462, 2.03482306, 1.93304396, 1.81565921,
1.691556 , 1.55849392, 1.41691554, 1.26443803, 1.09788805,
0.91749089, 0.73341392, 0.55976308, 0.41020535, 0.28154122,
0.17129448, 0.06766872, -0.03752494])
hod_param_names = [r'$\rho_{sat}$',r'$\rho_{cen}$', r'$\log(M_1)$',r'$\log(M_0)$', r'$\sigma_{\log M }$',r'$\alpha$' ]
cosmo_param_names = [r'$\Omega_b h^2$', r'$\Omega_c h^2$', r'$w_0$', r'$n_s$', r'$\ln(10A_s)$', r'$H_0$', r'$N_{eff}$' ]
cosmo_params = {'simname': sim_info['simname'],
'boxno': sim_info['sim_hps']['boxno'],\
'realization': sim_info['sim_hps']['realization'],
'scale_factors':[sim_info['scale_factor']],\
'system': sim_info['sim_hps']['system']}
#cosmo_true_vals = [3.7,70.7317,-1.13151,0.12283, 3.11395, 0.953515, 0.021762]
cosmo_true_vals = [cat_val_dict[pn] for pn in chain_pnames if pn in cat_val_dict]
#cosmo_true_vals = [0.046*0.7**2, (0.27-0.046)*0.7**2, -1, 0.95, 3.5698, 70, 3.04]
#cosmo_true_vals = [MAP[idx] for idx, pn in enumerate(chain_pnames) if pn in cat_val_dict]
cosmo_pnames = ['ombh2', 'omch2', 'w0', 'ns', 'ln10As', 'H0', 'Neff']
cosmo_true_vals = np.array([0.0223, 0.1188, -1, 0.9667, 3.047, \
0.6774*100, 3.046]) #darksky
cat_val_dict = dict(zip(cosmo_pnames, cosmo_true_vals))
hod_params = sim_info['hod_params']
print hod_params
emu.get_param_bounds('logM1')
hod_params['logM1'] = 14.5
hod_true_vals = [hod_params[key] for key in chain_pnames if key in hod_params]
#hod_true_vals = [MAP[idx] for idx, key in enumerate(chain_pnames) if key in hod_params]
sim_cfg['sim_hps']['realization'] = 3
cat.load(sim_cfg['scale_factor'], HOD='zheng07', **sim_cfg['sim_hps'])
pop_xi = np.zeros((10, emu.scale_bin_centers.shape[0]))
for i in xrange(10):
cat.populate(hod_params)
pop_xi[i] = np.log10(cat.calc_ds(r_bins) )#, do_jackknife = False) )
pop_xi.std(axis =0)
fig = plt.figure(figsize = (10,7))
plt.errorbar(rbc, true_data[-len(emu.scale_bin_centers):], yerr=yerr, label = 'Data')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop', lw = 5)
for px in pop_xi:
plt.plot(rbc, 10**px, alpha = 0.5, color = 'k')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
plt.errorbar(rbc, np.ones_like(rbc), yerr=yerr/true_data[-len(emu.scale_bin_centers):], label = 'Data')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop', lw = 5)
for px in pop_xi:
plt.plot(rbc, 10**px/true_data[-len(emu.scale_bin_centers):],
alpha = 0.5, color = 'k')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
plt.xscale('log')
plt.legend(loc='best')
plt.show();
Out[132]:
<HDF5 dataset "data": shape (2, 18), type "<f8">
Out[134]:
array([142.07055415, 125.36222848, 103.00123614, 80.78440022,
61.34877064, 45.34181648, 32.86317666, 23.20920992,
15.90243135, 10.67781224, 6.94123681, 4.52700817,
3.08310536, 2.19672846, 1.65761567, 1.32605013,
1.05937352, 0.81363773])
Out[137]:
array([3.89166303, 3.53048346, 2.99295716, 2.34505852, 1.84542799,
1.38661878, 1.01137786, 0.70144696, 0.49340637, 0.36470645,
0.27175743, 0.20433438, 0.15172411, 0.11886243, 0.09431151,
0.07946101, 0.07196712, 0.0684937 ])
Out[138]:
array([0.02739247, 0.02816226, 0.02905749, 0.02902861, 0.03008093,
0.03058146, 0.03077541, 0.03022278, 0.0310271 , 0.03415554,
0.03915115, 0.04513674, 0.04921146, 0.05410884, 0.05689589,
0.05992308, 0.06793366, 0.08418206])
Out[139]:
<matplotlib.image.AxesImage at 0x7f3513f60750>
Out[140]:
array([3.89166303, 3.53048346, 2.99295716, 2.34505852, 1.84542799,
1.38661878, 1.01137786, 0.70144696, 0.49340637, 0.36470645,
0.27175743, 0.20433438, 0.15172411, 0.11886243, 0.09431151,
0.07946101, 0.07196712, 0.0684937 ])
Out[141]:
array([2.00649767e+02, 1.57480055e+02, 1.28415185e+02, 1.12737547e+02,
9.71384334e+01, 8.06208497e+01, 6.45537066e+01, 4.91696419e+01,
3.45138794e+01, 2.20857766e+01, 1.23689818e+01, 6.03034709e+00,
2.98785302e+00, 2.08923712e+00, 1.63010276e+00, 1.24582206e+00,
9.74488539e-01, 7.89157062e-01, 3.89166303e+00, 3.53048346e+00,
2.99295716e+00, 2.34505852e+00, 1.84542799e+00, 1.38661878e+00,
1.01137786e+00, 7.01446959e-01, 4.93406371e-01, 3.64706446e-01,
2.71757430e-01, 2.04334383e-01, 1.51724113e-01, 1.18862426e-01,
9.43115135e-02, 7.94610145e-02, 7.19671247e-02, 6.84937013e-02])
Out[143]:
{'H0': (61.69472, 74.76751999999999),
'Neff': (2.62125, 4.27875),
'ln10As': (3.0009, 3.179424),
'logM1': (13.7, 14.7),
'ns': (0.9278462, 0.9974495999999999),
'ombh2': (0.02066455, 0.02371239),
'omch2': (0.1012181, 0.13177679999999997),
'w0': (-1.399921, -0.5658486)}
fig = plt.figure(figsize = (10,7))
chain_samples = np.random.choice(low_om_chain.shape[0], size = 100, replace = False)
for sample in low_om_chain[chain_samples]:
param_dict = dict(zip(emu.get_param_names(), sample))
param_dict.update(fixed_params)
plt.plot(rbc, 10**emu.emulate_wrt_r(param_dict)[0], alpha = 0.2)
plt.errorbar(rbc, true_data[-len(emu.scale_bin_centers):], yerr=yerr, label = 'Data', color = 'k')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop')#, lw = 5)
plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
chain_samples = np.random.choice(high_om_chain.shape[0], size = 100, replace = False)
for sample in high_om_chain[chain_samples]:
param_dict = dict(zip(emu.get_param_names(), sample))
param_dict.update(fixed_params)
plt.plot(rbc, 10**emu.emulate_wrt_r(param_dict)[0]/true_data[-len(emu.scale_bin_centers):], alpha = 0.2)
#plt.errorbar(rbc, np.ones(len(emu.scale_bin_centers)), yerr=yerr/true_data[-len(emu.scale_bin_centers):], label = 'Data')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop')#, lw = 5)
plt.xscale('log')
#plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
chain_samples = np.random.choice(low_om_chain.shape[0], size = 100, replace = False)
for sample in low_om_chain[chain_samples]:
param_dict = dict(zip(emu.get_param_names(), sample))
param_dict.update(fixed_params)
plt.plot(rbc, 10**emu.emulate_wrt_r(param_dict)[0]/true_data[-len(emu.scale_bin_centers):], alpha = 0.2)
#plt.errorbar(rbc, np.ones(len(emu.scale_bin_centers)), yerr=yerr/true_data[-len(emu.scale_bin_centers):], label = 'Data')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop')#, lw = 5)
plt.xscale('log')
#plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
chain_samples = np.random.choice(med_om_chain.shape[0], size = 100, replace = False)
for sample in med_om_chain[chain_samples]:
param_dict = dict(zip(emu.get_param_names(), sample))
param_dict.update(fixed_params)
plt.plot(rbc, 10**emu.emulate_wrt_r(param_dict)[0]/true_data[-len(emu.scale_bin_centers):], alpha = 0.2)
#plt.errorbar(rbc, np.ones(len(emu.scale_bin_centers)), yerr=yerr/true_data[-len(emu.scale_bin_centers):], label = 'Data')
#plt.plot(rbc, 10**true_pred, label = 'True')
#plt.plot(rbc, 10**MAP_pred, label = 'MAP')
#plt.plot(rbc, 10**pop_xi.mean(axis = 0), label = 'Pop')#, lw = 5)
plt.xscale('log')
#plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
plt.errorbar(rbc, true_data[-len(emu.scale_bin_centers):], yerr=yerr, label = 'Data')
plt.plot(rbc, 10**true_pred, label = 'True')
plt.plot(rbc, 10**MAP_pred, label = 'MAP')
plt.loglog()
plt.legend(loc='best')
plt.show();
fig = plt.figure(figsize = (10,7))
plt.errorbar(rbc, np.zeros_like(true_data[-len(emu.scale_bin_centers):]), yerr=yerr/true_data[-len(emu.scale_bin_centers):], label = 'Data')
#plt.plot(rbc, (10**true_pred-true_data[-len(emu.scale_bin_centers):])/true_data[-len(emu.scale_bin_centers):], label = 'True')
plt.plot(rbc, (10**MAP_pred-true_data[-len(emu.scale_bin_centers):])/true_data[-len(emu.scale_bin_centers):], label = 'MAP')
plt.plot(rbc, (10**low_om_pred-true_data[-len(emu.scale_bin_centers):])/true_data[-len(emu.scale_bin_centers):], label = 'Low Om')
plt.plot(rbc, (10**high_om_pred-true_data[-len(emu.scale_bin_centers):])/true_data[-len(emu.scale_bin_centers):], label = 'High Om')
plt.xscale('log')
plt.legend(loc='best')
plt.show();
(10**true_pred)/true_data[-len(emu.scale_bin_centers):]
Out[147]:
['ombh2',
'omch2',
'w0',
'ns',
'ln10As',
'H0',
'Neff',
'logM1',
'logM0',
'sigma_logM',
'alpha',
'conc_gal_bias']
Out[151]:
['ombh2',
'omch2',
'w0',
'ns',
'ln10As',
'H0',
'Neff',
'logM1',
'logM0',
'sigma_logM',
'alpha',
'conc_gal_bias']
Out[152]:
{'H0': 65.7317,
'Neff': 3.2,
'alpha': 1.083,
'conc_gal_bias': 1.0,
'ln10As': 3.06395,
'logM0': 13.2,
'logM1': 14.2,
'ns': 0.971515,
'ombh2': 0.022762900000000003,
'omch2': 0.11283,
'sigma_logM': 0.2,
'w0': -0.861513}
if obs == 'wp':
true_data = true_data*100/true_param_dict['H0']
else:
true_data = true_data*(true_param_dict['H0']/100)**3
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-156-460ddf2bf1a7> in <module>()
----> 1 emu._kernels[bin][0].rbf.lengthscale
AttributeError: 'LemonPepperWet' object has no attribute '_kernels'